<template>
    <!--  <div class="container">
         <div class='login_content'>
           <div class='user_photo'><open-data type="userAvatarUrl"></open-data></div>
           <div class='user_nickname'><open-data type="userNickName"></open-data></div>
           <button  v-if="canIUse" class="login_btn" open-type="getUserInfo" @getuserinfo="bindGetUserInfo">点击授权登录</button>
           <div v-else>请升级微信版本</div>
         </div>
     </div> -->
    <div class="login_content">
        <div class="back"><img src="https://file.loveciy.net/web/login/back.png" /></div>
        <button class="login_btn" open-type="getUserInfo" @getuserinfo="bindGetUserInfo"></button>
    </div>
</template>
<script>
    export default {
        data () {
            return {
                canIUse: wx.canIUse('button.open-type.getUserInfo')
            }
        },
        methods: {
            bindGetUserInfo(e){
                var _this=this;
                wx.getUserInfo({
                    success:res =>{
                        _this.$store.dispatch('setUserInfo',res);   //把获取到的用户的信息存放在vuex中进行管理
                        _this.$request.postData('https://zlz.loveciy.net/api/auth/wxLogin',{raw_data:res.rawData,signature:res.signature,code:_this.$store.state.modulesUser.userCode}).then(res =>{
                            if(res.data.level=="success")
                            {
                                wx.setStorageSync('userToken',res.data.data);
                                wx.switchTab({
                                    url:"/pages/home/main"
                                })
                            }else{
                                _this.$currency.showToast(res.data.message,'none',2500)
                            }
                        })
                    }
                })
            }
        },
    }
</script>
<style scoped>
    .login_content{width: 100%;height:100%;position: absolute;}
    .back{width: 100%;height: 100%}
    .back img{width: 100%;height: 100%}
    .login_btn{background-image:url('http://file.loveciy.net/web/login/btn-login.png');background-repeat: no-repeat;background-size: 130px 47.27px;border:none;width:130px;height: 47.27px;bottom: 130px;background-color:#fff;}
    /*.login_content{width: 100%;position: absolute;left: 0;top: 20%;}
    .user_photo{width: 200px;margin:0 auto;}
    .user_nickname{text-align: center;margin-top: 20px}
    button{margin-top: 30px;border-radius:2px;width: 68%;margin-left: 15%;border: solid 1px green;background-color: white;color: green}*/
</style>
